package com.coocaa.ops.api.base.third.media.source.feign;

import com.coocaa.ops.api.base.third.FeignServiceNameConstants;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @author bijiahao
 * @date : 2019/7/1.
 * @description:
 *
 *     获取媒资策略的 fallback处理
 *
 */
@Slf4j
@Component
public class GetPolicyFallBackFactory implements FallbackFactory<GetPolicyFeignClient> {

    @Override
    public GetPolicyFeignClient create(Throwable cause) {
        GetPolicyFeignClient getPolicyFeignClient = (@RequestParam final Map<String, String> params) -> {
            log.error(FeignServiceNameConstants.MEDIA_SOURCE_SERVICE + " 出现问题: " + cause.toString() + ", 进行熔断处理!");
            return "";
        };
        return getPolicyFeignClient;
    }
}
